<?php
/**
 * Custom DjTpl tags and filters
 *
 * tag {% alphabet %}
 *
 * @link http://webappkit.net
 * @package webappkit
 * @subpackage db
 * @author J.Ducastel <nospam0@ducastel.name>
 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
 */
class djtplTagNode_alphabet extends djtplTagNode {

    /**
    * builds itself from tokens
    * @param djtplToken &$selfToken
    * @param array &$nextTokens djangoTplToken
    * @access public
    * @return bool
    */
    function buildFromTokens(&$selfToken, &$nextTokens) {
        // $this->token=&$selfToken;
        /*$def=$selfToken->tagdef;
        $regex='( reversed)?';
        if (ereg($regex,$def,$search)) {
            $this->reversed=$search[0]?true:false;
        } else {
            // error !
            trigger_error('invalid structure for tag for : '.$def);
        }*/
        $this->buildChildNodesFromTokens($nextTokens);
        return true;
    }/**/

    /**
    * is the node atomic (has no children)
    * @access public
    * @return bool
    */
    function isAtomic() {
        return false;
    }/**/

    /**
    * renders as string
    * @param djangoTplContext $context
    * @access public
    * @return string
    */
    function render(&$context) {
        $rendered='';
        $letters = array('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z');

        // setting empty array to avoid a bug when main container is an object
        $context->setPath('alphabet',array());
        foreach ($letters as $letter) {
            // setting loop vars
            $context->setPath('alphabet.letter',$letter);
            // rendering content
            $rendered.=$this->renderChildNodes($context);
        }
        return $rendered;
    }/**/
/*------------------------------------------------------------------------------
                                                                      properties
------------------------------------------------------------------------------*/
    /**
    * @var string tag name
    */
    var $tagname='alphabet';

}